# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.
#
# Old Maintainer: farawayer <farwayer@gmail.com>
# Old Co-Maintainer: Bert Peters <bert@bertptrs.nl>

_gemname=terminal-table
pkgname="ruby-$_gemname"
pkgver=3.0.2
pkgrel=5
pkgdesc='Simple, feature rich ascii table generation library.'
arch=(any)
url='https://github.com/tj/terminal-table'
license=('MIT')
depends=('ruby' 'ruby-unicode-display-width')
options=(!emptydirs)
source=(https://github.com/tj/terminal-table/archive/v${pkgver}.tar.gz)
sha512sums=('5e8aa375fb1a5d2789ac0a735e5b5420261700b91650658e2b084bc9544cc195a1af329d157626b6aa4e738ad59a860245da15a099940ba68bbe0e937fd2574d')

prepare() {
  cd "$_gemname-$pkgver"

  sed -r 's|~>|>=|g' -i "$_gemname.gemspec" # don't give a fuck about rubys bla bla
  sed 's|git ls-files -z|find -type f -print0 \|sed "s,\\\\./,,g"|' \
    -i "$_gemname.gemspec"
}

build() {
  cd "$_gemname-$pkgver"

  gem build "$_gemname.gemspec"
}

package() {
  cd "$_gemname-$pkgver"

  _gemdir="$(ruby -e'puts Gem.default_dir')"

  gem install --ignore-dependencies --no-user-install -i "$pkgdir/$_gemdir" \
    -n "$pkgdir/usr/bin" "$_gemname-$pkgver.gem"

  rm "$pkgdir/$_gemdir/cache/$_gemname-$pkgver.gem"
}

